package homevideo_model

import (
	"iptv_server/v3/src/database"
)

type Play struct {
	ID uint `gorm:"primarykey" json:"id"`
	// // id         uint `gorm:"primaryKey"`
	Name       string `gorm:"type:varchar(100)" json:"name"`
	DetailID   uint   `gorm:"index" json:"-"`
	Url        string `gorm:"type:varchar(2048)" json:"url"`
	// Parser     string `gorm:"-" json:"parser"`
	PlayerArgs string `gorm:"type:varchar(2048)" json:"playerArgs,omitempty"`
}

func GetPlay(id int) (p *Play, err error) {
	p = new(Play)
	err = database.DB.First(&p, id).Error
	// err = errors.New("do no thing")

	return
}

func (p *Play) Create() (err error) {
	err = database.DB.Create(p).Error
	return
}

func (p *Play) Save() (err error) {
	err = database.DB.Save(p).Error
	return
}
